package com.dc.refactoring._1_重新组织函数._2_InlineMethod;

/**
 * Description: 内联函数
 * @author: gdc
 * @date: 2020/11/13
 * @version 1.0
 */
public class Test {
    int number;

    public int getRatingOld() {
        return moreThenFiveNumber() ? 1 : 2;
    }

    /**
     * 函数的本体与名称同样清楚易懂
     */
    public boolean moreThenFiveNumber() {
        return number > 5;
    }

    // ---------------------------------------------------------------

    public int getRatingNew() {
        return number > 5 ? 1 : 2;
    }


    public static void main(String[] args){
        Test test = new Test();
        assert test.getRatingOld() == 1;
        assert test.getRatingNew() == 1;
    }
}
